#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json

from ManageDaemon.view.ResultModel import ResultModel
from utils.ActionSession import hasActionSession, readActionSession
from utils.MyJsonResponse import errorResponse


def getActionSession(request):
    id = request.GET.get("id")
    if id is None:
        return errorResponse("下载任务id参数不能为空")

    if not hasActionSession(id):
        return errorResponse("不存在下载任务")
    actionSession = readActionSession(id)
    if actionSession is None:
        return errorResponse("无效的id")
    return actionSession



